package com.note.exception;

/**
 * @ClassName GlobalResponseAdvice
 * @Description TODO
 * @Author QiBin
 * @Date 2020/6/1111:15
 * @Version 1.0
 **/


import org.springframework.context.annotation.Configuration;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;


/**
 * @author jack-cooper
 * @version 1.0.0
 * @ClassName GlobalReturnConfig.java
 * @Description 全局返回统一封装
 * @createTime 2019年11月08日 15:51:00
 */
//@EnableWebMvc
//@Configuration
//@RestControllerAdvice
//public class GlobalResponseAdvice implements ResponseBodyAdvice<Object> {
//
//    @Override
//    public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType) {
//        return true;
//    }
//
//    @Override
//    public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType selectedContentType, Class<? extends HttpMessageConverter<?>> selectedConverterType, ServerHttpRequest request, ServerHttpResponse response) {
//        if (body instanceof Response) {
//            return body;
//        } else {
//            return Response.success(body);
//        }
//    }
//}
